package edu.tju.dorm;

import java.sql.SQLException;

import java.util.List;

import com.ibatis.sqlmap.client.SqlMapClient;
import com.younker.waf.db.IBatisConfig;



public class IbatisDormDao implements IDormDao{
	protected SqlMapClient sqlMap = IBatisConfig.getSqlMapInstance();



	
	public void deleteDorm(long id) throws SQLException {
		
		sqlMap.delete("deleteDorm", id);
	}

	@SuppressWarnings("unchecked")
	
	public List<Dorm> getDormAnd(Dorm dorm) throws SQLException {
		
		return  sqlMap.queryForList("getDormAnd", dorm);
	}

	
	public Dorm getDormById(long id) throws SQLException {
		
		return (Dorm) sqlMap.queryForObject("getDormById", id);
	}

	
	public List<Dorm> getDormOr(Dorm dorm) throws SQLException {
		// TODO Auto-generated method stub
		return null;
	}

	
	public Long insertDorm(Dorm dorm) throws SQLException {
		
		return (Long)sqlMap.insert("insertDorm", dorm); 
	}

	
	public int updateDorm(Dorm dorm) throws SQLException {
		
		return sqlMap.update("updateDorm", dorm);
	}

}
